using System.Collections.Generic;
using TimeMachine.Engine.Metrics;
using TimeMachine.Engine.Storing;
using System.Linq;

namespace TimeMachine.Engine.Vcs
{
	public interface ICommitsInfoProvider
	{
		IEnumerable<DetailedCommitInfo> Get();
		IEnumerable<DetailedCommitInfo> GetFresh();
		DetailedCommitInfo Get(int rev);
	}

	public static class CommitInfoProviderExtensions
	{
		public static IEnumerable<CommitMetric> GetCommitMetrics(this ICommitsInfoProvider commits, string metricId, IMetricsStorage metricValues)
		{
			return commits.Get().Select(c => new CommitMetric(c, metricValues.GetValue(metricId, c.Revision)));
		}
	}
}